<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/css/main.css" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/css/common.css" />
    <link rel="stylesheet" type="text/css" href="/Public/Admin/css/bootstrap.min.css" />
   <!-- <link rel="stylesheet" type="text/css" href="/Public/Admin/extend/static/h-ui.admin/css/H-ui.admin.css" />-->
    <![endif]-->
    <title>申请列表</title>
</head>
<body>
<div class="contant">
<div class="row">
    <div class="content applylist">
        <div class="box">
            <h1>申请录入</h1>
            <div class="list-block">
                <div class="row">
                    <a class="ml-5" onClick="apply_add('新增客户','<?php echo U('Admin/Apply/add');?>')" href="javascript:;" title="新增客户">
                        <button class="addcus"><span></span>新增客户</button>
                    </a>

                </div>
                <div class="row">
                <form id="form-search" action='<?php echo U("Apply/index");?>' class="form-inline text-right m-b-5 fr">
                    <label>用户名称:</label> <input type="text" name="user_name" placeholder="请输入名称" value=<?php echo ($_GET['user_name']); ?> >
                    <label>手机号:</label> <input type="text" name="telephone" placeholder="请输入手机号" value=<?php echo ($_GET['telephone']); ?> >
                    <label>录入时间:</label> <input type="date" name="create_time_beg" placeholder="请选择时间" value=<?php echo ($_GET['create_time_beg']); ?>><em>~</em>
                    <input type="date" name="create_time_end" placeholder="请选择时间" value=<?php echo ($_GET['create_time_end']); ?>>
                    <input id="order" type="hidden" name="order" value=<?php echo ($_GET['order']); ?>>
                    <label>状态:</label>
                        <select name="status" class="form-control">
                        <?php if(is_array($statusItems)): foreach($statusItems as $k=>$_tS): if($k == $_GET['status'] and $k != 0): ?><option value=<?php echo ($k); ?> selected><?php echo ($_tS); ?></option>
                            <?php else: ?>
                                <option value=<?php echo ($k); ?>><?php echo ($_tS); ?></option><?php endif; endforeach; endif; ?>
                        </select>
                    <button class="search" type="submit"><img src="/Public/Admin/images/search.png" alt="">查询</button>
                </form>
                </div>
                <div class="row">
                    <table class="list">
                        <tr>
                            <th>编号</th>
                             <th><a href="#" class="bule" onclick="orderByThis(this)" data-target=<?php echo ($_GET['order']==1 or $_GET['order']==2)?$_GET['order']:1; ?>>申请人</a></th>
                             <th><a href="#" class="bule" onclick="orderByThis(this)" data-target=<?php echo ($_GET['order']==3 or $_GET['order']==4)?$_GET['order']:3; ?>>身份证号</a></th>
                             <th>手机号</th>
                             <th><a href="#" class="bule" onclick="orderByThis(this)" data-target=<?php echo ($_GET['order']==7 or $_GET['order']==6)?$_GET['order']:8; ?>>业务部门</a></th>
                             <th>申请时间</th>
                             <th>状态</th>
                             <th>进入当前状态时间</th>
                             <!-- <th>审核状态</th> -->
                             <th><a href="#" class="bule" onclick="orderByThis(this)" data-target=<?php echo ($_GET['order']==5 or $_GET['order']==6)?$_GET['order']:5; ?>>银行</a></th>
                             <th>操作</th>
                        </tr>

                        <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$user): $mod = ($i % 2 );++$i;?><tr>
                                <td><?php echo ($user["entry_no"]); ?></td>
                                <td><?php echo ($user["user_name"]); ?></td>
                                <td><?php echo ($user["identity_no"]); ?></td>
                                <td><?php echo ($user["telephone"]); ?></td>
                                <td><?php echo ($user["department_name"]); ?></td>
                                <td><?php echo (date('Y-m-d H:i:s', $user["create_time"])); ?></td>
                                <td>
                                <?php switch($user["check_status"]): case "-6": ?>征信拒贷<?php break;?>
                                    <?php case "-5": ?>征信待提交<?php break;?>
                                    <?php case "-4": ?>待央行征信查询<?php break;?>
                                    <?php case "-3": ?>待公检法审核<?php break;?>
                                    <?php case "-2": ?>待同盾审核<?php break;?>
                                    <?php case "-1": ?>申请待提交<?php break;?>
                                    <?php case "0": ?>待业务内勤审核<?php break;?>
                                    <?php case "1": ?>待业务经理审核<?php break;?>
                                    <?php case "2": ?>待审核助理审核<?php break;?>
                                    <?php case "3": ?>待审核专员审核<?php break;?>
                                    <?php case "4": ?>待审核主管审核<?php break;?>
                                    <?php case "5": ?>待审核经理审核<?php break;?>
                                    <?php case "6": ?>垫资申请待添加<?php break;?>
                                    <?php case "7": ?>待财务助理审核<?php break;?>
                                    <?php case "8": ?>待财务打款<?php break;?>
                                    <?php case "9": ?>待垫资资料补录<?php break;?>
                                    <?php case "10": ?>待抄单资料确认<?php break;?>
                                    <?php case "11": ?>待合同抄单<?php break;?>
                                    <?php case "12": ?>待内勤主管审核<?php break;?>
                                    <?php case "13": ?>合同待送行<?php break;?>
                                    <?php case "14": ?>合同待接收<?php break;?>
                                    <?php case "15": ?>银行合同待送回<?php break;?>
                                    <?php case "16": ?>银行合同待接收<?php break;?>
                                    <?php case "18": ?>合同待送公证处<?php break;?>
                                    <?php case "19": ?>合同待收回<?php break;?>
                                    <?php case "20": ?>合同公证待确认<?php break;?>
                                    <?php case "21": ?>抵押资料待寄送渠道<?php break;?>
                                    <?php case "22": ?>抵押资料待渠道确认<?php break;?>
                                    <?php case "23": ?>合同待送行<?php break;?>
                                    <?php case "24": ?>抵押资料待补录<?php break;?>
                                    <?php case "25": ?>公司资料待转交<?php break;?>
                                    <?php case "26": ?>待银行确认收到<?php break;?>
                                    <?php case "27": ?>归档资料待递交<?php break;?>
                                    <?php case "28": ?>归档资料待送行<?php break;?>
                                    <?php case "29": ?>资料待归档<?php break;?>
                                    <?php case "30": ?>资料已归档<?php break;?>
                                    <?php default: ?>default<?php endswitch;?>
                                </td>
                                <td><?php echo (date('Y-m-d H:i:s', $user["update_time"])); ?></td>
                                <td class="my-bank" id="mybank<?php echo ($user["id"]); ?>" data-id=<?php echo ($user["id"]); ?> data-toggle="modal" data-target="#modifyBank"><?php echo ($user["bank_short_name"]); ?></td>
                                <td>
                                <?php if($user['check_status'] == -1): ?><a href="<?php echo U('apply/detail_info?user_id='.$user['id']);?>">编辑</a>&nbsp;&nbsp;
                                    <?php elseif($user['check_status']== -5): ?>
                                        <a href="<?php echo U('apply/edit?user_id='.$user['id']);?>">修改</a>
                                        <?php else: ?>
                                    <a href="<?php echo U('apply/detail_info?user_id='.$user['id']);?>">查看</a>&nbsp;&nbsp;<?php endif; ?>
                                <?php if($user['check_status'] < 0 ): ?><a class="blue" href="<?php echo U('apply/addAssure?user_id='.$user['id']);?>">添加担保人</a>
                                    <?php else: endif; ?>
                                </td>
                            </tr><?php endforeach; endif; else: echo "" ;endif; ?>
                    </table>
                </div>
                <?php echo ($page); ?>
            </div>
        </div>
    </div>
</div>


<!-- Modal -->
<div class="modal fade" id="modifyBank" tabindex="-1" role="dialog" aria-labelledby="modifyBankLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="modifyBankLabel">更改贷款银行</h4>
      </div>
      <div class="modal-body">
        <div id="bank_select">
            <label>银行:</label>
            <select id="bank" name="loan_bank_id" class="form-control">
            <?php if(is_array($bankList)): foreach($bankList as $k=>$_bank): ?><option value=<?php echo ($_bank["id"]); ?>><?php echo ($_bank["bank_short_name"]); ?></option><?php endforeach; endif; ?>
            </select>
            <input type="hidden" id="user-id">
        </div>
      </div>

      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">取消修改</button>
        <button id="modify-bank" type="button" class="btn btn-primary">提交更改</button>
      </div>
    </div>
  </div>
</div>
</div>
<script type="text/javascript" src="/Public/Admin/extend/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/Public/Admin/extend/static/h-ui.admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
    function apply_add(title,url) {
        layer_full(title,url);
    }
    function orderByThis(elm_o) {
        var orderVal = $(elm_o).attr('data-target');

        if (orderVal%2 == 0) {
            $(elm_o).attr('data-target',numSub(orderVal,1));
        }else{
            $(elm_o).attr('data-target',numAdd(orderVal,1));
        }

        var newOrderVal = $(elm_o).attr('data-target');

        $('#order').val(newOrderVal);

        $('#form-search').submit();

        console.log(orderVal);
    }

    // 传递user-id
    $('.my-bank').click(function(){
        var userId = $(this).attr('data-id');
        $('#user-id').val(userId);
    });

    // 提交更改银行
    $('#modify-bank').click(function(){
        var userId   = $('#user-id').val();
        var bankId   = $('#bank').val();
        var bankName = $("#bank").find("option:selected").text();

        $.ajax({
           type: "POST",
           url: "/index.php?s=/Admin/Apply/modifyBank",
           data: {
                user_id:userId,
                bank_id:bankId
            },
           success: function(msg){
                console.log(msg);
                if (msg == 1) {
                    alert('更改成功');
                    $('#mybank'+userId).html(bankName);
                    return false;
                }else{
                    msg = $.parseJSON(msg);
                    alert(msg.message);
                }
           }
        });

        $(this).attr('data-dismiss','modal');
    });
</script>
</body>
</html>